package com.smdk.dsminio.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smdk.dsminio.dao.DsminioFolderInfoMapper;
import com.smdk.dsminio.entity.DsminioFolderInfo;
import com.smdk.dsminio.service.DsminioFolderInfoService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (DsminioFolderInfo)表服务实现类
 *
 * @author 神秘的凯
 * @since 2020-10-28 15:09:25
 */
@Service
public class DsminioFolderInfoServiceImpl extends ServiceImpl<DsminioFolderInfoMapper, DsminioFolderInfo> implements DsminioFolderInfoService {

    @Override
    public boolean addDsminioFolderInfo(DsminioFolderInfo dsminioFolderInfo) {
        return this.save(dsminioFolderInfo);
    }

    @Override
    public boolean deleteDsminioFolderInfo(Long id) {
        return this.removeById(id);
    }

    @Override
    public boolean updateDsminioFolderInfo(DsminioFolderInfo dsminioFolderInfo) {
        return this.updateById(dsminioFolderInfo);
    }

    @Override
    public List<DsminioFolderInfo> searchDsminioFolderInfo(Long topObjectListId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("topObjectListId", topObjectListId);
        return this.list(queryWrapper);
    }

    @Override
    public List<DsminioFolderInfo> searchDsminioFolderInfoByBucketId(Long bucketId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("bucketId", bucketId);
        return this.list(queryWrapper);
    }

    @Override
    public boolean searchFolderCount(Long bucketId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("bucketId", bucketId);
        return this.count(queryWrapper) > 0 ? false : true;
    }
}